#include <climits>
#include <iostream>
#include <iomanip>
using namespace std;
bool is_leap_year(int year)
{
    return (year%4==0 && year%100!=0)|| (year%400==0);
}

int GetMonthDay(int year,int month)
{
    static int months_arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    if (month==2 && is_leap_year(year))
        return 29;
    else
        return months_arr[month]; 
}

class Date
{
public:
    Date(int year,int month,int day)
        :_year(year)
        ,_month(month)
        ,_day(day)
    {}
    void printdate(int days)
    {
        while (days>GetMonthDay(_year,_month)) 
        {
            days-=GetMonthDay(_year,_month);
            _month++;
            if (_month==13)
            {
                _month=0;
                _year++;
            }
        }
        _day=days;
        printf("%d-%02d-%02d",_year,_month,_day);
    }

    int _year;
    int _month;
    int _day;
};

int main() 
{
    int year,days;
    cin>>year>>days;
    Date d(year,1,0);
    d.printdate(days);
    return 0;
}
